package com.huawei.appgallery.forum.cards.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.hwid.core.constants.HwAccountConstants;
import o.bsp;
import o.bsy.a;
import o.bsy.b;
import o.bsy.c;
import o.bsy.e;
import o.bsy.h;
import o.bsy.j;
import o.dof;

public class HotSpotUserTextView extends LinearLayout {
    private int ʻ;
    private Context ˊ;
    private TextView ˋ;
    private TextView ˎ;
    private ImageView ˏ;
    private int ॱ;

    public HotSpotUserTextView(Context context) {
        super(context);
        ॱ(context);
    }

    public HotSpotUserTextView(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        ॱ(context);
    }

    public HotSpotUserTextView(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ॱ(context);
    }

    private void ॱ(Context context) {
        this.ˊ = context;
        View inflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(b.ˏॱ, this);
        this.ˎ = (TextView) inflate.findViewById(c.ॱʾ);
        this.ˏ = (ImageView) inflate.findViewById(c.ՙ);
        this.ˋ = (TextView) inflate.findViewById(c.ॱʿ);
    }

    public void setData(User user, int i, int i2) {
        Object string;
        String string2;
        if (i > 999) {
            string = this.ˊ.getString(j.ᐝ, new Object[]{Integer.valueOf(999)});
        } else {
            String quantityString = this.ˊ.getResources().getQuantityString(h.ˎ, i, new Object[]{Integer.valueOf(i)});
        }
        if (i2 > 999) {
            string2 = this.ˊ.getString(j.ʽ, new Object[]{Integer.valueOf(999)});
        } else {
            string2 = this.ˊ.getResources().getQuantityString(h.ॱ, i2, new Object[]{Integer.valueOf(i2)});
        }
        Object obj = HwAccountConstants.BLANK + this.ˊ.getString(j.ʼ, new Object[]{string, string2});
        this.ˋ.setVisibility(0);
        this.ˋ.setText(obj);
        this.ˎ.setTextSize(1, 8.0f);
        this.ʻ = bsp.ˏ(this.ˋ, obj);
        setUser(user);
    }

    public void setUser(User user) {
        int i = 0;
        if (user == null) {
            this.ˎ.setVisibility(8);
            this.ˏ.setVisibility(8);
            return;
        }
        int i2;
        int dimensionPixelSize;
        if (user.ʻ()) {
            this.ˏ.setVisibility(0);
            this.ˏ.setImageResource(a.ʻ);
            i2 = 1;
        } else if (user.ᐝ()) {
            this.ˏ.setVisibility(0);
            this.ˏ.setImageResource(a.ॱॱ);
            i2 = 1;
        } else {
            this.ˏ.setVisibility(8);
            i2 = 0;
        }
        if (i2 != 0) {
            dimensionPixelSize = this.ˊ.getResources().getDimensionPixelSize(e.ʾ) + this.ˊ.getResources().getDimensionPixelSize(e.ʼॱ);
        } else {
            dimensionPixelSize = 0;
        }
        if (dof.ॱ(user.ˋ())) {
            this.ˎ.setVisibility(8);
        } else {
            this.ˎ.setVisibility(0);
            this.ˎ.setText(user.ˋ());
            i = 1;
        }
        int ˏ = bsp.ˏ(this.ˎ, user.ˋ());
        LayoutParams layoutParams = (LayoutParams) this.ˎ.getLayoutParams();
        if (i != 0) {
            if (i2 != 0) {
                dimensionPixelSize = (this.ॱ - dimensionPixelSize) - this.ʻ;
            } else {
                dimensionPixelSize = this.ॱ - this.ʻ;
            }
            if (dimensionPixelSize > ˏ) {
                layoutParams.width = -2;
            } else {
                layoutParams.width = dimensionPixelSize;
            }
        }
        this.ˎ.setLayoutParams(layoutParams);
    }

    public void setContentWidth(int i) {
        this.ॱ = i;
    }

    public void setUserNickNameColorDark(int i) {
        this.ˎ.setTextColor(i);
    }
}
